package spzx.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import spzx.auth.NoAuthProperties;
import spzx.auth.SysUserAuthInterceptor;

@Configuration
public class ManagerConfiguration implements WebMvcConfigurer {
    @Autowired
    private SysUserAuthInterceptor sysUserAuthInterceptor;

    @Autowired
    NoAuthProperties noAuthProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        registry.addInterceptor(sysUserAuthInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        noAuthProperties.getNoAuth()
                        /*"/admin/sysUser/getValidateCode",
                        "/admin/sysUser/index/login",
                        //这四个路径是API文档的资源路径
                        "/doc.html",
                        "/webjars/**",
                        "/favicon.ico",
                        "/v3/api-docs/**"*/
        );
    }
}
